package utils

import (
	"fmt"
	"os"
	"path/filepath"
	"strings"
)

func FindGitDirectories(root string) []string {
	var gitDirs []string

	err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if info.IsDir() && strings.HasSuffix(path, ".git") {
			gitDirs = append(gitDirs, filepath.Dir(path))
		}
		return nil
	})

	if err != nil {
		fmt.Println("Error:", err)
	}

	return gitDirs
}
